Page({
  data: {
    type: '',
    pageTitle: '',
    mapInfo: {
      latitude: 30.593116,
      longitude: 114.305649,
      markers: [
        {
          id: 1,
          latitude: 30.593116,
          longitude: 114.305649,
          title: '中心广场',
          iconPath: '/assets/icons/marker-square.png',
          width: 30,
          height: 30
        },
        {
          id: 2,
          latitude: 30.594116,
          longitude: 114.306649,
          title: '儿童乐园',
          iconPath: '/assets/icons/marker-play.png',
          width: 30,
          height: 30
        }
      ],
      legends: [
        { type: 'square', name: '广场', icon: '/assets/icons/marker-square.png' },
        { type: 'play', name: '游乐场', icon: '/assets/icons/marker-play.png' },
        { type: 'food', name: '餐饮', icon: '/assets/icons/marker-food.png' },
        { type: 'wc', name: '卫生间', icon: '/assets/icons/marker-wc.png' }
      ]
    },
    guideList: []
  },

  onLoad(options) {
    const { type } = options
    this.setData({ type })
    this.initPageData(type)
  },

  // 初始化页面数据
  initPageData(type) {
    let pageTitle = ''
    let guideList = []

    switch(type) {
      case 'map':
        pageTitle = '公园地图'
        break
      case 'culture':
        pageTitle = '文化导览'
        guideList = [
          {
            id: 1,
            title: '文化展览馆',
            description: '常年展出本地历史文化展览，设有互动体验区。周二至周日开放，免费参观。',
            imageUrl: '/assets/images/culture1.jpg',
            distance: '50m',
            tags: ['免费开放', '互动体验'],
            latitude: 30.593116,
            longitude: 114.305649
          }
        ]
        break
      case 'entertainment':
        pageTitle = '娱乐项目'
        guideList = [
          {
            id: 1,
            title: '拓高乐园',
            description: '大型户外拓展乐园，设有攀岩墙、丛林穿越等项目，适合亲子互动。',
            imageUrl: '/assets/images/entertainment1.jpg',
            distance: '100m',
            tags: ['亲子互动', '户外拓展'],
            latitude: 30.594116,
            longitude: 114.306649
          }
        ]
        break
      case 'food':
        pageTitle = '美食指南'
        guideList = [
          {
            id: 1,
            title: '湖畔咖啡',
            description: '环境优美的湖畔咖啡馆，提供特色咖啡、简餐及下午茶。',
            imageUrl: '/assets/images/food1.jpg',
            distance: '150m',
            tags: ['咖啡', '简餐'],
            latitude: 30.595116,
            longitude: 114.307649
          }
        ]
        break
      case 'sports':
        pageTitle = '文体活动'
        guideList = [
          {
            id: 1,
            title: '全民健身广场',
            description: '配备专业健身器材，每天早晚有免费的健身操课程。',
            imageUrl: '/assets/images/sports1.jpg',
            distance: '200m',
            tags: ['免费课程', '健身器材'],
            latitude: 30.596116,
            longitude: 114.308649
          }
        ]
        break
    }

    this.setData({
      pageTitle,
      guideList
    })
  },

  // 导航到位置
  onLocation(e) {
    const { item } = e.currentTarget.dataset
    wx.openLocation({
      latitude: item.latitude,
      longitude: item.longitude,
      name: item.title,
      address: item.description
    })
  }
}) 